#! /bin/sh
testenv=$1
level=$2
jobname=$3
module=$4
project=$5
build_num=$6

case "$testenv" in
        "test")
                echo "测试环境"
                cat ../settings/hosts/test/hosts > /etc/hosts
                ;;
        "demo")
                echo "灰度环境"
                cat ../settings/hosts/demo/hosts > /etc/hosts
                ;;
        "product")
                echo "线上环境"
                cat ../settings/hosts/product/hosts > /etc/hosts
                ;;
		"autotest")
                echo "自动化环境"
                cat ../settings/hosts/autotest/hosts > /etc/hosts
                ;;
        *)
                #其它输入
                ;;
esac

#执行自动化脚本
time=$(date "+%Y%m%d-%H%M%S")
outputdir="/home/rfoutput/$jobname/$testenv/$build_num"
tmpdir=${outputdir//\//Q_Q}
dir2=${tmpdir//\:/C_C}
levelstr="-i $level"

case "$level" in
        "level1")
		#不做处理
                ;;
        "level2")
               	levelstr=$levelstr"ORlevel1"
                ;;
        "level3")
                levelstr=$levelstr"ORlevel1ORlevel2"
				;;
	"all")
		levelstr=""
		;;
esac

echo $levelstr

mkvirtualenv $jobname
workon $jobname
cd ../case/$project 
pip install -r requirements.txt
pybot -v testenv:$testenv -v default_output_dir:$dir2 -E colon:CL -E slash:Q  $levelstr -e notrun -R $outputdir/output.xml -d $outputdir $module 
